package com.xiaozhen.quartz.feign.fallback;

import com.xiaozhen.common.core.domain.R;
import com.xiaozhen.common.core.domain.driver.param.ModbusParam;
import com.xiaozhen.common.core.domain.driver.vo.ModbusDriverVo;
import com.xiaozhen.quartz.feign.DeviceService;
import com.xiaozhen.quartz.feign.ModbusService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * HISTORY
 *
 * @author zhenweisheng
 * @date 2021/11/17 11:50
 * @description:
 */
@Slf4j
public class DeviceServiceFallback implements FallbackFactory<DeviceService> {

    @Override
    public DeviceService create(Throwable throwable) {
        log.error("获取设备信息调用失败:{}", throwable.getMessage());
        return new DeviceService() {

            @Override
            public R<ModbusDriverVo> getModbusDeviceInfo(Long deviceId) {
                return R.fail("获取设备信息失败:" + throwable.getMessage());
            }
        };
    }
}
